package edu.nf.ch03.tool;

import edu.nf.ch03.entity.Choice;
import edu.nf.ch03.entity.Question;
import edu.nf.ch03.mapper.ChoiceMapper;
import edu.nf.ch03.mapper.QuestionMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Component;

/**
 * @author wangl
 * @date 2025/4/19
 * 工具列表
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class AppTools {

    private final ChoiceMapper choiceMapper;

    private final QuestionMapper questionMapper;

    /**
     * 出选择题的工具
     * @param choices
     */
    @Tool(description = "创建选择题")
    public void saveChoice(Choice[] choices) {
        for(Choice choice : choices) {
            log.info(choice.getTopic());
            choiceMapper.saveChoice(choice);
        }
    }

    @Tool(description = "创建问答题")
    public void saveQuestion(Question[] questions) {
        for(Question question : questions) {
            log.info(question.getQuestion());
            questionMapper.saveQuestion(question);
        }
    }

}